home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / smtlbox / frmmain.txt < prev    next >
Text File  |  1994-10-16  |  10KB  |  338 lines

  1. 'General Declarations
  2. Const WM_NCLBUTTONDOWN = &HA1
  3. Const HTCAPTION = 2
  4.  
  5. Declare Function Sendmessage Lib "User" (ByVal hWnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, lParam As Any) As Long
  6. Declare Sub ReleaseCapture Lib "User" ()
  7. Declare Function GetactiveWindow Lib "User" () As Integer
  8.  
  9. Dim Focus As Integer
  10.  
  11. '//////////////////////////////////////////////////
  12. ' WINDOWBUILD
  13. '//////////////////////////////////////////////////
  14.  
  15. Sub Form_GotFocus ()
  16. TitleBarObject.BackColor = active_Title_BAr
  17. '//////////////////////////////////////////////////
  18.         'Events for this object:
  19.          'Load
  20.          'Unload
  21.          'Gotfocus
  22.          'LostFocus
  23.          'MouseDown
  24.          'MouseUp
  25.          'DblClick
  26.          'KeyDown
  27.          'Resize
  28. '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  29. End Sub
  30.  
  31. Sub Form_KeyDown (KEYCODE As Integer, Shift As Integer)
  32. '//////////////////////////////////////////////////
  33.         'Events for this object:
  34.          'Load
  35.          'Unload
  36.          'Gotfocus
  37.          'LostFocus
  38.          'MouseDown
  39.          'MouseUp
  40.          'DblClick
  41.          'KeyDown
  42.          'Resize
  43. '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  44. Dim ShiftDown, Altdown, CtrlDown
  45.     
  46.    Const KEY_F4 = &H73
  47.     'Const KEY_F2 = &H71 ' Define constants.
  48.  
  49.     Const ALT_MASK = 4
  50.     Altdown = (Shift And ALT_MASK) > 0
  51.     
  52.  
  53.     If KEYCODE = KEY_sPACE Then    ' Display key combinations.
  54.  
  55.     If ShiftDown And CtrlDown And Altdown Then
  56.  
  57.     ElseIf ShiftDown And Altdown Then
  58.  
  59.     ElseIf ShiftDown And CtrlDown Then
  60.  
  61.     ElseIf CtrlDown And Altdown Then
  62.  
  63.     ElseIf ShiftDown Then
  64.  
  65.     ElseIf CtrlDown Then
  66.      
  67.     ElseIf Altdown Then
  68.     picControlMenu_Mouseup 1, 0, 0, 0
  69.  
  70.     ElseIf Shift = 0 Then
  71.  
  72.     End If
  73.  
  74.     End If
  75.  
  76.     If KEYCODE = KEY_F4 Then
  77.     If Altdown Then
  78.     End
  79.     End If
  80.     End If
  81. '//////////////////////////////////////////////////
  82.         'Events for this object:
  83.          'Load
  84.          'Unload
  85.          'Gotfocus
  86.          'LostFocus
  87.          'MouseDown
  88.          'MouseUp
  89.          'DblClick
  90.          'KeyDown
  91.          'Resize
  92. '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  93.  
  94. End Sub
  95.  
  96. Sub Form_Load ()
  97.     
  98.     Call WindowBuild(frmMain, WindowBorder1, TitleBarObject, picControlMenu)
  99.     ' Pass it the names of the objects that make up the Window.' Call WindowBuild a second time to eliminate flicker
  100.         Call WindowBuild(frmMain, WindowBorder2, TitleBarObject, picControlMenu)
  101.             Focus = True 'To color the window approprietly
  102.                 Timer1.Interval = 10 'Enable timer to catch events
  103. ' Code for "INI" File
  104.    ' frmMain.Top = GetPrivateProfileInt(SECTION, "Top", 0, INIFILENAME)
  105.    ' frmMain.Left = GetPrivateProfileInt(SECTION, "Left", 0, INIFILENAME)
  106.    ' frmMain.Height = GetPrivateProfileInt(SECTION, "Height", Screen.Height, INIFILENAME)
  107.    ' frmMain.Width = GetPrivateProfileInt(SECTION, "Width", Screen.Width, INIFILENAME)
  108. '//////////////////////////////////////////////////
  109.         'Events for this object:
  110.          'Load
  111.          'Unload
  112.          'Gotfocus
  113.          'LostFocus
  114.          'MouseDown
  115.          'MouseUp
  116.          'DblClick
  117.          'KeyDown
  118.          'Resize
  119. '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  120.         End Sub
  121.  
  122. Sub Form_LostFocus ()
  123. Dim i As Integer
  124. i = GetactiveWindow()
  125. MsgBox "" + Str$(i)
  126. '//////////////////////////////////////////////////
  127.         'Events for this object:
  128.          'Load
  129.          'Unload
  130.          'Gotfocus
  131.          'LostFocus
  132.          'MouseDown
  133.          'MouseUp
  134.          'DblClick
  135.          'KeyDown
  136.          'Resize
  137. '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  138. End Sub
  139.  
  140. Sub Form_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single)
  141.  
  142. If Focus = True Then
  143.     TitleBarObject.BackColor = active_Title_BAr
  144. Else
  145.     TitleBarObject.BackColor = active_Title_BAr
  146. End If
  147. '//////////////////////////////////////////////////
  148.         'Events for this object:
  149.          'Load
  150.          'Unload
  151.          'Gotfocus
  152.          'LostFocus
  153.          'MouseDown
  154.          'MouseUp
  155.          'DblClick
  156.          'KeyDown
  157.          'Resize
  158. '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  159. End Sub
  160.  
  161. Sub Form_MouseUp (Button As Integer, Shift As Integer, X As Single, Y As Single)
  162. Focus = True
  163. Timer1.Interval = 10
  164. '//////////////////////////////////////////////////
  165.         'Events for this object:
  166.          'Load
  167.          'Unload
  168.          'Gotfocus
  169.          'LostFocus
  170.          'MouseDown
  171.          'MouseUp
  172.          'DblClick
  173.          'KeyDown
  174.          'Resize
  175. '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  176. End Sub
  177.  
  178. Sub Form_Resize ()
  179. WindowBuild frmMain, WindowBorder1, TitleBarObject, picControlMenu
  180. WindowBuild frmMain, WindowBorder2, TitleBarObject, picControlMenu
  181. '//////////////////////////////////////////////////
  182.         'Events for this object:
  183.          'Load
  184.          'Unload
  185.          'Gotfocus
  186.          'LostFocus
  187.          'MouseDown
  188.          'MouseUp
  189.          'DblClick
  190.          'KeyDown
  191.          'Resize
  192. '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  193. End Sub
  194.  
  195. Sub Form_Unload (Cancel As Integer)
  196.     Dim rc As Integer
  197.    
  198.     'Create the INI file
  199.     rc = WritePrivateProfileString(SECTION, ByVal "Top", ByVal Str$(frmMain.Top), INIFILENAME)
  200.     rc = WritePrivateProfileString(SECTION, ByVal "Left", ByVal Str$(frmMain.Left), INIFILENAME)
  201.     rc = WritePrivateProfileString(SECTION, ByVal "Height", ByVal Str$(frmMain.Height), INIFILENAME)
  202.     rc = WritePrivateProfileString(SECTION, ByVal "Width", ByVal Str$(frmMain.Width), INIFILENAME)
  203.     
  204.    
  205.     'Terminate the application
  206.     End
  207. '//////////////////////////////////////////////////
  208.         'Events for this object:
  209.          'Load
  210.          'Unload
  211.          'Gotfocus
  212.          'LostFocus
  213.          'MouseDown
  214.          'MouseUp
  215.          'DblClick
  216.          'KeyDown
  217.          'Resize
  218. '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  219. End Sub
  220.  
  221. Sub picControlMenu_DblClick ()
  222. Unload frmMain
  223. End
  224. '//////////////////////////////////////////////////
  225.         'Events for this object:
  226.          'DblClick
  227.          'MouseDown
  228.          'MouseUp
  229.          'Resize
  230. '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  231. End Sub
  232.  
  233. Sub picControlMenu_Mousedown (Button As Integer, Shift As Integer, X As Single, Y As Single)
  234. Focus = True
  235. Timer1.Interval = 10
  236. '//////////////////////////////////////////////////
  237.         'Events for this object:
  238.          'DblClick
  239.          'MouseDown
  240.          'MouseUp
  241.          'Resize
  242. '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  243. End Sub
  244.  
  245. Sub picControlMenu_Mouseup (Button As Integer, Shift As Integer, X As Single, Y As Single)
  246. TitleBarObject.BackColor = active_Title_BAr
  247. mousepointer = 5
  248. Focus = True
  249. Timer1.Interval = 10
  250. PopupMenu frmDummy.mnuSystemMenu, 0, 0, 9
  251. mousepointer = 0
  252. '//////////////////////////////////////////////////
  253.         'Events for this object:
  254.          'DblClick
  255.          'MouseDown
  256.          'MouseUp
  257.          'Resize
  258. '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  259. End Sub
  260.  
  261. Sub picControlMenu_Resize ()
  262. picControlMenu.Picture = Image1(1).Picture
  263. '//////////////////////////////////////////////////
  264.         'Events for this object:
  265.          'DblClick
  266.          'MouseDown
  267.          'MouseUp
  268.          'Resize
  269. '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  270. End Sub
  271.  
  272. Sub Timer1_Timer ()
  273.    If Focus = True Then
  274.     
  275.     If GetactiveWindow() <> frmMain.hWnd Then
  276.        'Do form's lost-focus routines here.
  277.  
  278.        Focus = False
  279.        WindowBorder1.BorderColor = Inactive_Border
  280.        TitleBarObject.BackColor = inactive_Title_BAr
  281.     Else
  282.       Focus = True
  283.     End If
  284.  
  285.    End If
  286. 'Only Event for this object
  287. '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  288. End Sub
  289.  
  290. Sub TitleBarObject_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single)
  291.  
  292. Focus = True
  293.     Timer1.Interval = 10
  294.     If Button <> 1 Then Exit Sub ' If not the left mouse button, ...exit
  295.     Dim ReturnVal%
  296.     ReleaseCapture
  297.     ReturnV